<template>
  <div class="comp" v-if="list.length > 0">
    <ul>
      <li
        v-for="item in list"
        :key="item.id"
        @click="gotoContent(item.id, item.title)"
      >
        <div class="left">
          <img v-lazy="item.cover" alt="" />
          <div class="play" v-if="isAudio">
            <van-icon name="play-circle" size="20" color="#fff" />
          </div>
        </div>
        <div class="right">
          <div class="title">
            <h3>{{ item.title }}</h3>
          </div>
          <div class="author">{{ item.author }}/{{ item.category }}</div>
          <div class="content">
            {{ item.content }}
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default() {
        return [];
      },
    },
    isAudio: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    gotoContent(id, title) {
      this.$emit("gotoContent", {
        id,
        title,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.comp {
  width: 100%;
}
$imgHeight: 60px;
ul {
  margin-top: 20px;
  li {
    display: flex;
    // height: 110px;
    padding: 14px 0;
    box-sizing: border-box;
    .left {
      flex-basis: $imgHeight;
      width: $imgHeight;
      height: 100%;
      position: relative;
      .play {
        position: absolute;
        bottom: 14px;
        left: 8px;
      }
      img {
        width: $imgHeight;
        height: $imgHeight + 16px;
      }
    }
    .right {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      padding-left: 10px;
      box-sizing: border-box;
      text-align: justify;
      .title {
        font-size: 18px;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }
      .author {
        font-size: 12px;
        color: #888;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        overflow: hidden;
      }
      .content {
        font-size: 12px;
        line-height: 1.4;
        color: #888;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }
    }
  }
}
</style>
